package xyz.thoughtset.viewer.apis.client.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import xyz.thoughtset.viewer.ai.mcp.client.factory.McpBotFactory;
import xyz.thoughtset.viewer.ai.mcp.client.service.McpBotInfoService;
import xyz.thoughtset.viewer.common.ai.model.factory.ModelsRegistry;
import xyz.thoughtset.viewer.common.api.controller.BaseController;
import xyz.thoughtset.viewer.common.core.util.ExtractConstantFieldUtil;
import xyz.thoughtset.viewer.modules.mcp.server.service.McpServerInfoService;

import java.util.Collection;

@RestController
@RequestMapping
public class AiSupportController extends BaseController {
    @Autowired
    private McpServerInfoService mcpServerInfoService;
    @Autowired
    private McpBotInfoService mcpBotInfoService;
    @Autowired
    private McpBotFactory mcpBotFactory;


    @GetMapping(value = "/publishServer")
    public void publishApi(@RequestParam String apiId){
        mcpServerInfoService.publishServer(apiId);
    }
    @GetMapping(value = "/unpublishedServer")
    public void unpublishedApi(@RequestParam String apiId){
        mcpServerInfoService.unpublishedServer(apiId);
    }
    @GetMapping(value = "/supportProvider")
    public Object supportProvider(){
        return ModelsRegistry.supportProvider();
    }
    @GetMapping(value = "/modelPurposes")
    public Object modelPurposes(){
        return ExtractConstantFieldUtil.extractEnumToList(xyz.thoughtset.viewer.common.ai.model.entity.purpose.ModelPurposeEnum.class);
    }
    @GetMapping(value = "/publishBot")
    public void publishBot(@RequestParam String apiId){
        mcpBotInfoService.publishServer(apiId);
    }
    @GetMapping(value = "/unpublishedBot")
    public void unpublishedBot(@RequestParam String apiId){
        mcpBotInfoService.unpublishedServer(apiId);
    }
    @GetMapping(value = "/mcpTools")
    public Object mcpTools(@RequestParam String objId){
        return mcpBotFactory.clientTools(objId);
    }
    @GetMapping(value = "/workingBots")
    public Object workingBots(){
        return mcpBotInfoService.workingBots();
    }

}
